public class Graph {
    public final  static int INFINITY = Integer.MAX_VALUE;  //无穷大
    private int vexNum;      //图的当前顶点数和边数
    private VNode[] vexs;          //顶点
    private ArcNode[][] arcs;           //邻接矩阵

    public Graph(){
        this(0,null,null);
    }

    public Graph(int vexNum, VNode[] vexs, ArcNode[][] arcs) {
        this.vexNum = vexNum;
        this.vexs = vexs;
        this.arcs = arcs;
    }




    //创建有向网
    public void createDN() {
        vexNum = 10;
        vexs = new VNode[10];
        vexs[0] = new VNode("合肥");
        vexs[1] = new VNode("北京");
        vexs[2] = new VNode("上海");
        vexs[3] = new VNode("重庆");
        vexs[4] = new VNode("广州");
        vexs[5] = new VNode("南京");
        vexs[6]= new VNode("深圳");
        vexs[7] = new VNode("桂林");
        vexs[8] = new VNode("昆明");
        vexs[9] = new VNode("西安");
        arcs = new ArcNode[10][10];
        for(int v =0;v < 10 ;v++) {    //初始化邻接矩阵
            for (int u = 0; u < 10; u++) {
                arcs[v][u] = null;
            }
        }

        //1~2
        arcs[0][1] = new ArcNode(new Flight("CA1544",1055,"733"),vexs[0],960);
        arcs[0][1] = new ArcNode(new Flight("CA1544",1055,"733"),vexs[2],960);
        arcs[0][1] = new ArcNode(new Flight("CA1544",1055,"733"),vexs[3],960);

        //2~1
        arcs[1][0] = new ArcNode(new Flight("CA1555",1155,"744"),vexs[2],960);
        arcs[1][0] = new ArcNode(new Flight("CA1555",1155,"744"),vexs[1],960);

        //3~4
        arcs[2][3] = new ArcNode(new Flight("MU5341",1420,"M90"),vexs[1],1280);
        arcs[2][3] = new ArcNode(new Flight("MU5341",1420,"M90"),vexs[4],1280);
        arcs[2][3] = new ArcNode(new Flight("MU5341",1420,"M90"),vexs[2],1280);

        //4~3
        arcs[3][2] = new ArcNode(new Flight("MU5344",1520,"755"),vexs[0],1280);
        arcs[3][2] = new ArcNode(new Flight("MU5344",1520,"755"),vexs[1],1280);
        arcs[3][2] = new ArcNode(new Flight("MU5344",1520,"755"),vexs[3],1280);

        //1~3
        arcs[0][2] = new ArcNode(new Flight("MU5355",1620,"766"),vexs[0],500);
        arcs[0][2] = new ArcNode(new Flight("MU5355",1620,"766"),vexs[1],500);
        arcs[0][2] = new ArcNode(new Flight("MU5355",1620,"766"),vexs[3],500);

        //3~1
        arcs[0][2] = new ArcNode(new Flight("MU5366",1720,"777"),vexs[1],500);
        arcs[0][2] = new ArcNode(new Flight("MU5366",1720,"777"),vexs[2],500);

        //2~4
        arcs[1][3] = new ArcNode(new Flight("MU5377",1820,"788"),vexs[1],1000);
        arcs[1][3] = new ArcNode(new Flight("MU5377",1820,"788"),vexs[2],1000);
        arcs[1][3] = new ArcNode(new Flight("MU5377",1820,"788"),vexs[4],1000);

        //4~2
        arcs[3][1] = new ArcNode(new Flight("MU5388",1920,"799"),vexs[0],1000);
        arcs[3][1] = new ArcNode(new Flight("MU5388",1920,"799"),vexs[2],1000);
        arcs[3][1] = new ArcNode(new Flight("MU5388",1920,"799"),vexs[3],1000);

        //2~3
        arcs[1][2] = new ArcNode(new Flight("MU5399",2020,"800"),vexs[0],1500);
        arcs[1][2] = new ArcNode(new Flight("MU5399",2020,"800"),vexs[1],1500);
        arcs[1][2] = new ArcNode(new Flight("MU5399",2020,"800"),vexs[3],1500);

        //3~2
        arcs[2][1] = new ArcNode(new Flight("MU5400",2120,"811"),vexs[0],1500);
        arcs[2][1] = new ArcNode(new Flight("MU5400",2120,"811"),vexs[2],1500);
        arcs[2][1] = new ArcNode(new Flight("MU5400",2120,"811"),vexs[3],1500);

        //4~5
        arcs[3][4] = new ArcNode(new Flight("MU5411",2220,"822"),vexs[5],900);

        //5~6
        arcs[4][5] = new ArcNode(new Flight("CZ3869",855,"733"),vexs[4],1010);
        arcs[4][5] = new ArcNode(new Flight("CZ3869",855,"733"),vexs[6],1010);

        //6~5
        arcs[5][4] = new ArcNode(new Flight("CZ3879",866,"833"),vexs[5],1010);

        //6~7
        arcs[5][6] = new ArcNode(new Flight("CZ3889",877,"844"),vexs[7],800);

        //7~8
        arcs[6][7] = new ArcNode(new Flight("MU3682",2050,"M90"),vexs[6],1060);
        arcs[6][7] = new ArcNode(new Flight("MU3682",2050,"M90"),vexs[8],1060);

        //8~7
        arcs[7][6] = new ArcNode(new Flight("MU3692",2150,"855"),vexs[7],1060);

        //8~9
        arcs[7][8] = new ArcNode(new Flight("MU3702",2250,"866"),vexs[9],700);

        //9~10
        arcs[8][9] = new ArcNode(new Flight("HUI1836",1015,"738"),vexs[8],1250);


        //10~9
        arcs[9][8] = new ArcNode(new Flight("HUI1846",1115,"748"),vexs[9],1250);

    }
    public int getVexNum(){
        return vexNum;
    }

    public VNode[] getVexs(){
        return vexs;
    }

    public ArcNode[][] getArcs(){
        return arcs;
    }









    public void toStringGraph() {
        for (int i = 0; i < vexNum; i++) {
            for (int j = 0; j < vexNum; j++) {
                System.out.print(arcs[i][j] + "\t");
            }
            System.out.println();
        }
    }
}
